package com.qf.commons.sentinel.listener;

import com.alibaba.csp.sentinel.Tracer;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.qf.commons.core.exception.IExceptionListener;

/**
 * description: Sentinel熔断降级的异常记录监听器
 * author: Ken
 * 公众号：Java架构栈
 */
public class SentinelExceptionListener implements IExceptionListener {

    @Override
    public void exceptionListener(Throwable t) {
        //如果不是Sentinel自己的异常，熔断器就会记录该异常
        if (!BlockException.isBlockException(t)) {
            Tracer.trace(t);
        }
    }
}
